import axios from 'axios'; 
import { ChnmuseumHost, UserAgent } from '../../config/variable';
 
export const getQrCode = () => {
  const params = {
    registerClient: 1,
    appType: 'wxscan',
    redirectUrl: 'aHR0cHM6Ly91dS5jaG5tdXNldW0uY24vIw=='
  };
  return axios.get(`${ChnmuseumHost}/prod-api/api/getWechatCode`, {
    params,
    headers: {
      'Content-Type': 'application/json',
      'User-Agent': UserAgent
    }
  });
};

export const getUserInfo = (token) => {
  return axios.get(`${ChnmuseumHost}/prod-api/getUserInfoToIndividual2Mini`, {
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${token}`,
      'User-Agent': UserAgent
    }
  });
};

export const gainAllSystemConfigLogin = (token) => {
  const params = {
      channel: 'wxMini',
      requestTaskKey: 'gainAllSystemConfigLogin',
      ticketUseType: 1,
      p: 'wxmini'
  };
  return axios.get('https://wxmini.chnmuseum.cn/prod-api/basesetting/HallSetting/gainAllSystemConfigLogin', {
      headers: {
          'Content-Type': 'application/json',
          Authorization: `Bearer ${token}`,
          'User-Agent': UserAgent
      },
      params
  })
};

export const getCheckTime = () => {
  return axios.get('https://vv.video.qq.com/checktime?otype=json', {
      headers: {
          'Content-Type': 'application/json',
          'User-Agent': UserAgent
      }
  });
};


export const blockTick = (token, nonce) => {
  const params = {
      platform: 2,
      nonce,
      docType: 1,
      p: 'wxmini'
  };
  
  return axios.get('https://wxmini.chnmuseum.cn/prod-api/pool/getBlock', {
      headers: {
          'Content-Type': 'application/json',
          Authorization: `Bearer ${token}`,
          'User-Agent': UserAgent
      },
      params
  });
};

export const createOrder = (token, data, ip) => {
  return axios.post('https://wxmini.chnmuseum.cn/prod-api/config/orderRule/placeOrder', data, {
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${token}`,
        'User-Agent': UserAgent,
        'Host-Ip': ip
      }
  });
};
